Q: Why should I bother wrapping items in a ComboBoxItem?
2577
11-Mar-2011
Anonymous User
11-Mar-2011ComboBoxItem exposes some useful properties—IsSelected andIsHighlighted—and
useful events—Selected and Unselected. Using ComboBoxItem also avoids a quirkybehavior with showing content controls in the selection box (when IsEditable isfalse): If an item in a ComboBox is a content control, the entire controldoesn’t get displayed in the selection box. Instead, the inner content isextracted and shown. By using ComboBoxItem as the outermost content control,the inner content is now the entire control that you probably wanted to bedisplayed in the first place.
Because ComboBoxItem is a content control, it is also handy for adding simplestrings to a
ComboBox (rather than using something like TextBlock or Label).